﻿/// <reference path="../scripts/jquery-1.11.2.min.js" />
/// <reference path="../scripts/bootstrap.min.js" />

if (typeof ($) != "undefined" && $) {
    //验证用户
    CheckUser();
    $(document).ready(onReady);

}

function onReady() {
    $("#header").click(function () {
        window.location.href = "order.html";
    });

    $.ajax({
        type: "get",
        url: "api/member.ashx?ac=coupons&u=1&k=" + Math.random(),
        beforeSend: function () {
            $('#loadingToast').show();
        },
        error: function () {
            showToast("数据加载失败");
        },
        success: function (data) {
            var list = eval("(" + data + ")");
            for (var i = 0; i < list.length; i++) {
                var o = list[i];
                $("#cplist").append('<div class="stamp ' + o.Css + '" onclick="setCoupons(' + o.Id + ',' + o.Money + ')"><div class="par"><sub class="sign">￥</sub><span>' + o.Money + '.00</span><sub></sub><p>' + o.Explain + '</p></div><div class="copy">有效期<p>' + moment(o.YouXQStart).format('YYYY-MM-DD') + '<br>' + moment(o.YouXQEnd).format('YYYY-MM-DD') + '</p></div><i>' + o.Tip + '</i></div>');
            }
        },
        complete: function () {
            $('#loadingToast').hide();
        }
    });
}

function setCoupons(id, money) {
    //    $.cookie('cpid', id);
    //    $.cookie('cpm', money);
    window.location.href = 'order.html?cpid=' + id + '&cpm=' + money;
}

